#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <inttypes.h> 
#include <stdbool.h>
#include <errno.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "anysocket.h"
#include "log.h"
#include "utcache.h"
#include "connection-pool.h"
#include "networking.h"
#include "ursax.h"

struct foo_cache* cpool = NULL;

static void cpool_connection_dtor(void* arg)
{
	st_netfd_t stfd = (st_netfd_t)arg;
	st_netfd_close(stfd);
}

int connection_pool_init(size_t capacity)
{
	if (capacity == 0)
		capacity = 10240;

	cpool = foo_cache_create(capacity, &cpool_connection_dtor, true);
	return 0;
}

int connection_pool_fini()
{
	return foo_cache_delete(cpool, 0);
}
